package cn.wiseda.finance.utils;

import java.text.DecimalFormat;

/**
 * 转换工具类
 * 
 * @author wwei
 * 
 */
public abstract class TypeConverter {

	/**
	 * 将Double数据转换成Long型并以字符输出
	 * 
	 * @param Double
	 *            num
	 * @return String
	 */
	public static String convertMillion(Double num) {
		String number = null;
		if (num == null) {
			return "0.00";
		}
		// BigDecimal b = new BigDecimal(num / 10000);
		// double value = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		DecimalFormat df = new DecimalFormat("#,##0.00");
		number = df.format(num / 10000);
		// number = Long.toString(value);
		return number;
	}

	public static String convertPercentage(Double num) {
		DecimalFormat df = new DecimalFormat("#,##0.00");
		String percentage = df.format(num * 100) + "%";
		return percentage;
	}

}
